import re
from flask import Blueprint,request,jsonify
import json
from db import db1

bp_good = Blueprint('goods',__name__)

@bp_good.route('goodM',methods=['POST','GET'])
def goodM():
    if request.method=='POST':
        data = request.data
        if data:
            data = json.loads(data)
        else:
            data = request.form
        sql = "insert into goods values(0,'%s',%d)"%(data['name'],int(data['cid']))
        db1.insert(sql)

        return jsonify({'code':200})

    else:
        page = request.args.get('page')
        size = request.args.get('size')